﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;

namespace Arizu.Repository
{
    public class Notification
    {
        /// <summary>
        /// 发送邮件
        /// </summary>
        /// <param name="emailAddr"></param>
        /// <param name="title"></param>
        /// <param name="content"></param>
        public static void SendEmail(string emailAddr, string title, string content) 
        {
            string[] emailAdds = emailAddr.Split(',');

            SmtpClient client = new SmtpClient("smtp.gmail.com", 25);

            foreach (string item in emailAdds)
            {
                if (string.IsNullOrEmpty(item))
                {
                    continue;
                }

                MailMessage msg = new MailMessage(Constants.EmailAddress, item, title, content);

                client.UseDefaultCredentials = false;
                System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential(Constants.EmailAddress, Constants.Password);
                client.Credentials = basicAuthenticationInfo;
                client.EnableSsl = true;
                client.Send(msg);
            }
        }

        public void SendSMS()
        { 

        }
    }
}
